<#
接口关系提取（原生 PowerShell）
用途：提取 src/main/java 中的 interface 声明，生成 .reports/interface_relations/interfaces.txt。
用法：
  pwsh -File scripts/windows/list-interface-relations.ps1
#>
param()

$WindowsDir = Split-Path -Parent $PSCommandPath
$ScriptsDir = Split-Path -Parent $WindowsDir
$RepoDir = Split-Path -Parent $ScriptsDir

$javaDir = Join-Path $RepoDir 'src/main/java'
$outDir = Join-Path $RepoDir '.reports/interface_relations'
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
$outFile = Join-Path $outDir 'interfaces.txt'

$lines = @()
if (Test-Path $javaDir) {
  Get-ChildItem -Path $javaDir -Recurse -File -Include *.java | ForEach-Object {
    $txt = Get-Content -Raw $_.FullName
    $m = [regex]::Match($txt, '(?m)^\s*interface\s+(\w+)')
    if ($m.Success) {
      $name = $m.Groups[1].Value
      $rel = $_.FullName.Substring($RepoDir.Length).TrimStart('\','/')
      $lines += "$name => $rel"
    }
  }
}

Set-Content -Path $outFile -Value ($lines -join "`n")
Write-Host "已输出接口关系：$outFile"
exit 0
